home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Stacks / Hyper Utilities / XCMD's⁄XFCN's / Set⁄GetVolume / SetPVolume.Pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-02-27  |  1.9 KB  |  75 lines  |  [TEXT/ttxt]

  1. {$R-}
  2. {
  3.     SetPVolume -- An HyperCard XCMD that will set the volume of the speaker.
  4.                     and place the new volume into Parameter RAM.  This 
  5.                     routine will reset the control panel's volume level,
  6.                     so use it only when necessary.
  7.     
  8.         Written by Steven Kienle, CIS account number 72330,111
  9.     
  10.     SetPVolume should be called in HyperCard as
  11.         SetPVolume(<volume>)
  12.     Where <volume> is between 0 and 7.
  13.     
  14.     After compiling this program, link it with the SetPVolume.Link, then use
  15.     ResEdit to move the XCMD resource to the appropriate stack.  Or use the
  16.     GetVolume/SetVolume stack's Install SetPVolume button.
  17.     
  18.     NOTE:  for the XCmdGlue.inc file to work with TML Pascal, a few 
  19.            modifications are required.
  20. }
  21.  
  22. {$S SetPVolume }     { Segment name must be the same as the command name. }
  23.  
  24. UNIT DummyUnit;
  25.  
  26. INTERFACE
  27.  
  28. USES MacIntf, HyperXCmd;
  29.  
  30. PROCEDURE ENTRYPOINT(paramPtr: XCmdPtr);
  31.     
  32. IMPLEMENTATION
  33.  
  34. PROCEDURE SetPVolume(paramPtr: XCmdPtr); FORWARD;
  35.  
  36.   PROCEDURE ENTRYPOINT(paramPtr: XCmdPtr);
  37.   BEGIN
  38.     SetPVolume(paramPtr);
  39.   END;
  40.  
  41. PROCEDURE SetPVolume(paramPtr: XCmdPtr);
  42.     VAR
  43.         newVolume : LongInt ;
  44.         pasStr : Str255 ;
  45.         tempStr : Str31 ;
  46.         theParams : SysPPtr ;
  47.         theError : OSErr ;
  48.         Top5, Bottom8, VolBits : Integer ;
  49.  
  50.     {$I XCmdGlue.inc }
  51.  
  52.     BEGIN
  53.         ZeroToPas(paramPtr^.params[1]^,pasStr) ;    { first param is Volume }
  54.         tempStr := pasStr ;
  55.         newVolume := StrToNum(tempStr) ;{ Convert it to a Number }
  56.         
  57.             { Reset the Volume in the Parameter RAM }
  58.             
  59.         theParams := GetSysPPtr ;
  60.         Bottom8 := BitAnd(theParams^.volClik,$00FF) ;
  61.         Top5 := BitAnd(theParams^.volClik, $F800) ;
  62.         VolBits := newVolume * $0100 ;
  63.         theParams^.volClik := Top5 + VolBits + Bottom8 ;
  64.         theError := WriteParam ;
  65.         
  66.             { If there was an error, let the user know }
  67.             
  68.         If theError <> noErr then
  69.             SendCardMessage('answer "Big Trouble with writing Parameter Ram" with "OK"') ;
  70.         
  71.         SetSoundVol (newVolume) ;                 { Set the Current Volume }
  72.     END;
  73.  
  74. END.
  75.